<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">
</head>
<body>
<div id="app">
    <el-input
            placeholder="请输入内容"
            v-model="name"
            clearable size="small">
    </el-input>
    <el-input
            placeholder="请输入内容"
            v-model="salary"
            clearable size="small">
    </el-input>
    <el-input
            placeholder="请输入内容"
            v-model="job"
            clearable size="small">
    </el-input>
    <el-button size="mini"
                @click="f()">添加</el-button>
    <el-table
        :data="arr"
        style="width: 100%"
    border="true">
        <el-table-column
            type="index"
            label="编号"
            width="50">
        </el-table-column>
        <el-table-column
                prop="name"
                label="姓名"
                width="150">
        </el-table-column>
        <el-table-column
                prop="salary"
                label="工资"
                width="150">
        </el-table-column>
        <el-table-column
                prop="job"
                label="工作"
                width="180">
        </el-table-column>
        <el-table-column label="操作">
            <!--scope代表每行对应的数据里面的index属性对应数组下标
            里面的row代表每行对应的数组的对象
            可以在控制台输出row.属性名-->
            <template slot-scope="scope">
                <el-popconfirm @confirm="handleDelete(scope.$index, scope.row)"
                               title="这一段内容确定删除吗？"
                >
                    <!--confirm确认事件-->
                    <el-button
                            size="mini"
                            type="danger"
                            slot="reference">删除</el-button>
                </el-popconfirm>
            </template>
        </el-table-column>
    </el-table>
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script>
    let v=new Vue({
        el: '#app',
        data: function() {
            return {
                name:"",
                salary:"",
                job:"",
                arr:[],
            }
        },
        methods:{
            f(){
                if (v.name.trim()==""||v.salary.trim()==""||v.job.trim()==""){
                    return;
                }
                v.arr.push({name:v.name,salary:v.salary,job:v.job});
            },
            handleDelete(index, row){
                //删除arr数组中i下标位置的对象
                v.arr.splice(index,1);
                console.log(index+"  "+row.name+" "+row.salary+" "+row.job);
            }
        }
    })
</script>
</html>